package com.hp.ssmp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hp.ssmp.dao.CommentMapper;
import com.hp.ssmp.entity.TComment;
import com.hp.ssmp.entity.dto.TCommentDto;
import com.hp.ssmp.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

@Service("commentService")
@Transactional
public class CommentServiceImpl extends ServiceImpl<CommentMapper, TComment> implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    public Page<TCommentDto> getTCommentDtoPage(Integer currentPage, Integer pageSize,Long userid,Long status) {
        Page<TCommentDto> page = new Page<TCommentDto>(currentPage,pageSize);
        QueryWrapper<TCommentDto> wrapper = new QueryWrapper<TCommentDto>();
        if (userid != null && !"".equals(userid)) {
            wrapper.eq("c.userid", userid);
        }
        if (status != null && !"".equals(status)) {
            wrapper.eq("c.status", status);
        }

        return commentMapper.getCommentDtoByPage(page,wrapper);
    }
}
